<script setup>
import { ref } from 'vue'

const userStats = {
  totalResumes: 8,
  downloads: 126,
  shares: 45,
  achievements: 5
}

const savedResumes = ref([
  {
    id: 1,
    name: '游戏开发工程师简历',
    template: '像素冒险家',
    lastModified: '2024-03-20',
    downloads: 23,
    shares: 8,
    thumbnail: 'https://placekitten.com/300/400'
  },
  {
    id: 2,
    name: '前端开发简历',
    template: '复古街机',
    lastModified: '2024-03-18',
    downloads: 15,
    shares: 5,
    thumbnail: 'https://placekitten.com/301/400'
  }
])

const achievements = [
  {
    id: 1,
    name: '简历大师',
    description: '创建5份不同风格的简历',
    icon: '🏆',
    progress: 80
  },
  {
    id: 2,
    name: '人气之星',
    description: '简历被下载超过100次',
    icon: '⭐',
    progress: 60
  },
  {
    id: 3,
    name: '分享达人',
    description: '分享简历被查看50次',
    icon: '🌟',
    progress: 90
  }
]

const recentActivities = [
  {
    id: 1,
    type: 'create',
    content: '创建了新简历',
    date: '2024-03-20',
    icon: '📝'
  },
  {
    id: 2,
    type: 'download',
    content: '下载了简历',
    date: '2024-03-19',
    icon: '⬇️'
  },
  {
    id: 3,
    type: 'share',
    content: '分享了简历',
    date: '2024-03-18',
    icon: '🔗'
  }
]
</script>

<template>
  <div class="user-workspace">
    <div class="workspace-grid">
      <!-- 统计卡片 -->
      <div class="stats-section">
        <div class="stats-grid">
          <div class="stat-card pixel-card">
            <div class="stat-icon">📄</div>
            <div class="stat-info">
              <div class="stat-value">{{ userStats.totalResumes }}</div>
              <div class="stat-label">简历数量</div>
            </div>
          </div>
          <div class="stat-card pixel-card">
            <div class="stat-icon">⬇️</div>
            <div class="stat-info">
              <div class="stat-value">{{ userStats.downloads }}</div>
              <div class="stat-label">下载次数</div>
            </div>
          </div>
          <div class="stat-card pixel-card">
            <div class="stat-icon">🔗</div>
            <div class="stat-info">
              <div class="stat-value">{{ userStats.shares }}</div>
              <div class="stat-label">分享次数</div>
            </div>
          </div>
          <div class="stat-card pixel-card">
            <div class="stat-icon">🏆</div>
            <div class="stat-info">
              <div class="stat-value">{{ userStats.achievements }}</div>
              <div class="stat-label">获得成就</div>
            </div>
          </div>
        </div>
      </div>

      <!-- 已保存的简历 -->
      <div class="resumes-section pixel-card">
        <h2>我的简历</h2>
        <div class="resumes-grid">
          <div 
            v-for="resume in savedResumes"
            :key="resume.id"
            class="resume-card"
          >
            <div class="resume-preview">
              <img :src="resume.thumbnail" :alt="resume.name">
              <div class="resume-overlay">
                <button class="pixel-btn">编辑</button>
                <button class="pixel-btn">预览</button>
              </div>
            </div>
            <div class="resume-info">
              <h3>{{ resume.name }}</h3>
              <p class="template-name">模板：{{ resume.template }}</p>
              <div class="resume-meta">
                <span>{{ resume.lastModified }}</span>
                <div class="resume-stats">
                  <span>⬇️ {{ resume.downloads }}</span>
                  <span>🔗 {{ resume.shares }}</span>
                </div>
              </div>
            </div>
          </div>

          <!-- 创建新简历卡片 -->
          <div class="create-card pixel-card">
            <div class="create-content">
              <span class="create-icon">➕</span>
              <p>创建新简历</p>
            </div>
          </div>
        </div>
      </div>

      <!-- 成就系统 -->
      <div class="achievements-section pixel-card">
        <h2>我的成就</h2>
        <div class="achievements-grid">
          <div 
            v-for="achievement in achievements"
            :key="achievement.id"
            class="achievement-card"
          >
            <div class="achievement-icon">{{ achievement.icon }}</div>
            <div class="achievement-info">
              <h4>{{ achievement.name }}</h4>
              <p>{{ achievement.description }}</p>
              <div class="progress-bar">
                <div 
                  class="progress-fill"
                  :style="{ width: achievement.progress + '%' }"
                ></div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 最近活动 -->
      <div class="activities-section pixel-card">
        <h2>最近活动</h2>
        <div class="activity-list">
          <div 
            v-for="activity in recentActivities"
            :key="activity.id"
            class="activity-item"
          >
            <span class="activity-icon">{{ activity.icon }}</span>
            <div class="activity-content">
              <div class="activity-text">{{ activity.content }}</div>
              <div class="activity-date">{{ activity.date }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.user-workspace {
  padding: 1rem;
}

.workspace-grid {
  display: grid;
  gap: 2rem;
}

/* 统计卡片样式 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
}

.stat-icon {
  font-size: 2rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary-color);
  font-family: 'PixelFont', sans-serif;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* 简历列表样式 */
.resumes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.resume-card {
  background: white;
  border: var(--pixel-border) solid var(--text-primary);
  overflow: hidden;
  transition: transform 0.3s;
}

.resume-card:hover {
  transform: translate(-4px, -4px);
  box-shadow: var(--pixel-shadow);
}

.resume-preview {
  position: relative;
  height: 300px;
}

.resume-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.resume-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  opacity: 0;
  transition: opacity 0.3s;
}

.resume-preview:hover .resume-overlay {
  opacity: 1;
}

.resume-info {
  padding: 1rem;
}

.template-name {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.resume-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.resume-stats {
  display: flex;
  gap: 1rem;
}

.create-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  cursor: pointer;
  transition: all 0.3s;
  border: 2px dashed var(--text-secondary);
  background: transparent;
}

.create-card:hover {
  border-color: var(--primary-color);
  transform: translate(-4px, -4px);
  box-shadow: var(--pixel-shadow);
}

.create-content {
  text-align: center;
  color: var(--text-secondary);
}

.create-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  display: block;
}

/* 成就系统样式 */
.achievements-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.achievement-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--background-light);
  border: var(--pixel-border) solid var(--text-primary);
}

.achievement-icon {
  font-size: 2rem;
}

.achievement-info {
  flex: 1;
}

.progress-bar {
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  transition: width 0.3s;
}

/* 活动列表样式 */
.activity-list {
  margin-top: 1.5rem;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid #eee;
}

.activity-icon {
  font-size: 1.5rem;
}

.activity-date {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

h2 {
  font-family: 'PixelFont', sans-serif;
  color: var(--text-primary);
  font-size: 1.5rem;
}

h4 {
  margin: 0;
  color: var(--text-primary);
  font-family: 'PixelFont', sans-serif;
}
</style> 